home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 276-300 / disk_280 / graph / object.guidelines < prev    next >
Text File  |  1992-05-06  |  5KB  |  116 lines

  1. There are actually two types of objects (should I have two main object
  2. classes, inherited from a common root ?):
  3.  
  4. a) Objects which are visual (labels, lines, rectangles)
  5. b) Objects which exist semi-independtly from the graph (functions)
  6.  
  7. Objects of class b are selectable even if the graph is invalid, they have a
  8. name. Hence, as they can be selected other than by clicking on them, they are
  9. allowed to be 'invalid' (not displayable). All this is not allowed for
  10. class a). The name and ok fields serve these purposes, name must be a null
  11. string and ok true for class a).
  12.  
  13. The methods will be called as expected: all created objects will be deleted,
  14. selects will be followed by deselects, the sequence for down/move/up is
  15.  
  16. down, move, move, ..., up
  17.  
  18. select will be called if down returns true (the actual sequence is therefore:
  19. - if down returns FALSE   down
  20. - if down returns TRUE    down, select, move, move, ..., up
  21. )
  22.  
  23. The graph will be in a valid state (ok, window coords exisiting) when
  24. down/move/up/draw are called, but not necessarily so for all the other calls.
  25.  
  26.  
  27. Public fields:
  28. --------------
  29.  
  30. node node: used to keep objects in a list
  31. struct graph *g: the graph in which this object is
  32. int ok: object in a valid state ?
  33. int mx, my: These specify an offset to apply to the position of the mouse
  34. while it is moved around. This allows you to have an object picked up and
  35. moved around by an arbitray point (the mouse will maintain the same position
  36. relative to the objects origin thoughout, eg when dragging an object).
  37.  
  38. methods:
  39. --------
  40.  
  41. delete      no comment
  42.  
  43. select      you have been selected. You should probbaly highlight yourself.
  44.  
  45. deselect    Deselect yourself (dehighlight ?), return TRUE if the graph
  46.             needs redrawing (eg if you can't unhighlight cleanly).
  47.  
  48. down        Return true if graph's coordinates (in g->s.x,y) are inside you.
  49.             If you answer TRUE, you will be selected (cf select).
  50.  
  51. move        The mouse has moved. Do what you want (resize, drag, nothing).
  52.             Called only if you answered TRUE to down (Coordinates as above).
  53.  
  54. up          The mouse has been released. return TRUE if the graph needs
  55.             redrawing (eg if you moved).
  56.  
  57. edit        Allow the user detailed control over your placement, ... Return
  58.             TRUE if the object changed.
  59.  
  60. draw        Display thyself ! allow_mes is FALSE if called during refresh
  61.             (this mainly means that you can't display error messages).
  62.  
  63. improve     Improve your appearance (for functions mainly). Return TRUE if
  64.             graph needs redrawing.
  65.  
  66. f2str       Provide a concise (one line) textual description of yourself, in
  67.             buf (maximum size: maxlen). Return buf.
  68.  
  69. var_change  Is called for every object whenever a variable changes value. The
  70.             variable that has changed is passed. You should do whatever is
  71.             necessary to make sure that the next time you are displayed, you
  72.             reflect the new value of the variable.
  73.  
  74. save        Save yourself in the file. For the format, see load_<obj> below.
  75.  
  76. inform      Called for every object of a graph when it changes (for the moment,
  77.      
  78.             only when the dots per meter values change). This allows any
  79.             dependent values to be recalculated, any fonts to be loaded, etc
  80.             If this isn't possible (eg no memory left), return FALSE and
  81.             return to your previous state, otherwise return TRUE (but keep
  82.             enough information to return to your previous state without
  83.             needing any resources).
  84.  
  85. confirm     After an inform (to which you retuned TRUE), confirm is called
  86.             (before anything else), with ok being TRUE to confirm the
  87.             changes to the graph (you can now free any old resources), or
  88.             FALSE if the changes failed (return to the old state and free
  89.             any newly allocated resources).
  90.             Note: if you answered FALSE.to inform, this method won't get
  91.             called.
  92.  
  93. functions
  94. ---------
  95. You must also provide two functions to create the objects:
  96.  
  97. new_<objname>   Create a new instance of an object of class objname. Provide
  98.                 whatever initial parameters are necessary, or prompt the user.
  99.                 The main code will obviously have to be modified to allow
  100.                 creation of ant new object type ...
  101.  
  102. load_<objname>  Also creates a new instance, but with ant information loaded
  103.                 from disk (The file is one of the parameters). The format, in
  104.                 the file must be:
  105.  
  106.                 <object tag> a unique short for each type of object
  107.                 <any private data>
  108.                 <object end tag> another unique short
  109.  
  110.                 When load is called, the first tag has been read. load should
  111.                 check for data integrity, and the presence of the end_tag.
  112.                 NULL should be returned as an error.
  113.  
  114.                 The tags are centralised in file.h, to avoid errors.
  115.  
  116.